#ifndef VEC2_H
#define VEC2_H

template <class T>
class Vec2
{
public:
	Vec2() //: x(0), y(0) // the same as m_x = 0; m_y = 0;
	{
		x = 0;
		y = 0;
	}

	Vec2(T Tx, T Ty) //: m_x(x), m_y(y)
	{
		x = Tx;
		y = Ty;
	}
//sum operator
	Vec2& operator+= (const Vec2& rhs)
	{
		x += rhs.x;
		y += rhs.y;

		return *this;
	}

	Vec2 operator+ (const Vec2& a) const
	{
		Vec2 result = *this;
		result += a;
		return result;
	}
//minus operator
	Vec2& operator-= (const Vec2& rhs)
	{
		x -= rhs.x;
		y -= rhs.y;

		return *this;
	}

	Vec2 operator- (const Vec2& b) const
	{
		Vec2 result = *this;
		result -= b;
		return result;
	}
//multiplication operator
	Vec2& operator*= (float f)
	{
		x *= f;
		y *= f;

		return *this;
	}

	Vec2 operator* (float c) const
	{
		Vec2 result = *this;
		result *= c;
		return result;
	}
// division operator
	Vec2& operator/= (float f)
	{
		x /= f;
		y /= f;

		return *this;
	}

	Vec2 operator/ (float d) const
	{
		Vec2 result = *this;
		result /= d;
		return result;
	}

	Vec2 Normalise()
	{
		float total = x*x + y*y;
		total = sqrt(total);
		total = 1 / total;
		x *= total;
		y *= total;
		return *this;
	}

//private:
	T x, y;
};

typedef Vec2<int> Vec2i;
typedef Vec2<float> Vec2f;
typedef Vec2<double> Vec2d;

//template <class T>
//Vec2<T> operator+ (const Vec2<T>& a, Vec2<T>& b)
//{
//	//Vec2 result(a.m_x + b.m_y, a.m_y + b.m_y);		// or return Vec2 (a.m_x + b.m_y, a.m_y + b.m_y);
//
//	////result.m_x = a.m_x + b.m_y;		// same as above
//	////result.m_y = a.m_y + b.m_y;		// same as above
//
//	//return result;
//
//	Vec2<T> result = a;
//	result += b;
//	return result;		//preferable, uses operater += so just need to change the values of a and b
//}





#endif //VEC2_H